﻿package com.wandian.model.socket
{
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.AccountProxy;
	import com.wandian.model.GameRoomProxy;
	import com.wandian.model.InRoomPlayerDataProxy;
	import com.wandian.model.RoomInfoProxy;
	import com.wandian.model.UserInfoProxy;
	import com.wandian.model.socket.net.Command;
	import com.wandian.model.socket.net.TcpSocket;
	import com.wandian.model.socket.net.TcpSocketEvent;
	import com.wandian.model.vo.*;
	import com.wandian.util.CLZTiming;
	import com.wandian.util.word.WordFilter;
	
	import flash.events.TimerEvent;
	import flash.utils.ByteArray;
	import flash.utils.Dictionary;
	import flash.utils.Timer;
	
	import ghostcat.util.CountDown;
	
	import org.puremvc.as3.patterns.proxy.Proxy;

	/**
	* @author long
	* @QQ 108232706
	* @version 1.0
	*/
	public class ServerPacketProxy extends Proxy
	{
		private var _socket:TcpSocket;
		private var m_jsRead:int;
		private var m_timeid:Number;
		private var _timer:Timer;
		private var _nRoomId:int;
		private const RECONNECT_TIME:int=60000;
		private var _inRoomData:InRoomPlayerDataProxy;
		private var _global:GameData;
		private var _wordFilter:WordFilter;
		private var _userInfo:UserInfoProxy;
		private var _againLogin:Boolean=false;
		public static const NAME:String="ServerPacketProxy";


		public function ServerPacketProxy(data:Object=null)
		{
			this._global=GameData.getInstance();
			this._wordFilter=WordFilter.instance;
			super(NAME, data);
			this._socket=new TcpSocket();
			this._socket.addEventListener(TcpSocketEvent.CONNECT, this.onConnectHandler);
			this._socket.addEventListener(TcpSocketEvent.ERROR, this.onErrorHandler);
			this._socket.addEventListener(TcpSocketEvent.SECURITYERROR, this.onErrorHandler);
			this._socket.addEventListener(TcpSocketEvent.CLOSE, this.onCloseHandler);

			return;
		}

		private function onReconnectTimer(event:TimerEvent):void
		{
			return;
		}

		private function onErrorHandler(event:TcpSocketEvent):void
		{
			if (this._socket.hasEventListener(TcpSocketEvent.SYNC))
			{
				this._socket.removeEventListener(TcpSocketEvent.SYNC, this.onData);
			}
			GameData.isConnectSocket=false;
			return;
		}

		private function onConnectHandler(event:TcpSocketEvent):void
		{
			this._socket.addEventListener(TcpSocketEvent.SYNC, this.onData);
//			if (this._global.userInfo.userVo.gp != GameData.QZONE_SID)
//			{
//			}
//			if (this._global.userInfo.userVo.gp == GameData.FRIEND_SID)
//			{
//				this._socket.writeTGW(GameData.HOST, GameData.PORT);
//			}
			/*this._socket.writeBegin(Command.CMD_LOGIN);
			this._socket.writeInt(1); //this._global.userInfo.userVo.userid);
			this._socket.writeString(GameData.sesskey);
			this._socket.writeInt(1); //this._global.userInfo.userVo.gp);
			this._socket.writeEnd();
			this._socket.sendCmd();
			this._inRoomData=facade.retrieveProxy(InRoomPlayerDataProxy.NAME) as InRoomPlayerDataProxy;
			this._userInfo=facade.retrieveProxy(UserInfoProxy.NAME) as UserInfoProxy;*/
			//回调
//			CLZTiming.add(30, this.hbHandler);
			GameData.isConnectSocket=true;
			this.sendNotification(CLZNoticeName.CONNECT_SOCKET_SUCC);
			this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["CONNECTSOCKETSUCC"]});
			return;
		}

		private function onCloseHandler(event:TcpSocketEvent):void
		{
			if (this._socket.hasEventListener(TcpSocketEvent.SYNC))
			{
				this._socket.removeEventListener(TcpSocketEvent.SYNC, this.onData);
			}
			GameData.isConnectSocket=false;
			if (this._againLogin)
			{
				this._againLogin=false;
				return;
			}
			var objData:Object={okNoticeName: CLZNoticeName.RELOAD_WINDOW_PAGE, tip: GameData.tip["CONNECTSOCKETCLOSE"], tipTitle: GameData.tip["SYSTEM_TIP"], isCancel: false};
			this.sendNotification(CLZNoticeName.SHOW_WINDOWS_TIP, objData);
			return;
		}

		/**
		 * 接收到一个包命令
		 * @param event
		 */
		private function onData(event:TcpSocketEvent):void
		{
			event=null;
			var cmd:int=this._socket.cmd;
			this.ProcessServerCMD(cmd);
			return;
		}

		private function ProcessServerCMD(cmd:int):void
		{
			var objData:Object;
			var type:int;
			var errId:int;
			var publicCardLen:int;
			var arrPublicCard:Array;
			var bonusPoolLen:int;
			var arrBonusPool:Array;
			var playerNum:int;
			var playerVo:PlayerVo;
			var objPlayer:PlayerVo;
			var dealer:int;
			var playingNum:int;
			var obj:Object;
			var winCardNum:int;
			var winLen:int;
			var potLen:int;
			var isErr:int;
			var gold:uint;
			var rank:uint;
			var winRank:uint;
			var id:uint;
			var sumGold:int;
			var fromMid:uint;
			var fromName:String;
			var toGold:uint;
			var msg:String;
			var roomVo:RoomVo;
			var roomId:uint;
			var count:int;
			var money:Number;
			var sumMoney:Number;
			var toMid:uint;
			var arr:Array;
			var card1:String;
			var card2:String;
			var onLineTime:uint;
			var onLineNum:uint;
			var volume:int;
			var time:int;
			var strTip:String;
			var onLine:uint;
			var countTime:uint;
			var i:int;
			var seatId:int;
			var mid:int;
			var arrCardTypeTip:Array;
			var cardStr:String;
			var potNum:int;
			var potMoney:uint;
			var strErr:String;
			var userid:String;
			var msg:String;
			this._socket.readBegin();
			objData=new Object();
			trace("[收到命令]=============in==========in>cmd:" + cmd + " " + this._socket.cmdMap[cmd]);
			this._socket.printBodyData();
			switch (cmd)
			{
				case Command.CMD_FriendList: //大厅好友列表信息
				{
					(facade.retrieveProxy(UserInfoProxy.NAME) as UserInfoProxy).responseFriendList();
					break;
				}
				case Command.CMD_RoomUserList: //大厅看房间玩家信息
				{
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).responseRoomPlayerData();
					break;
				}
				case Command.CMD_REQUESTINFOMATION: //大厅看房间玩家信息
				{
					(facade.retrieveProxy(AccountProxy.NAME) as AccountProxy).responseInfomation();
					break;
				}
				case Command.CMD_RoomList: //房间列表
				{
					trace("Command.CMD_RoomList");
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).responseRoomList();
					break;
				}
				case Command.CMD_SETROOMINFO: //房间列表
				{
					trace("Command.CMD_SETROOMINFO");
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).responseSetRoomInfo();
					break;
				}
				case Command.CMD_ROOMINFOUPDATE:
				{
					trace("Command.CMD_ROOMINFOUPDATE");
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).responseRoomUpdate();
					break;
				}
				case Command.CMD_ROOMPLAYERNUMCHANGE:
				{
					trace("Command.CMD_ROOMSEATUPDATE");
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).responseRoomSeatUpdate();
					break;
				}
				case Command.CMD_LOGIN:
				{
					trace("Command.CMD_LOGIN");
					type=this._socket.readByte();
					//登录成功，取玩家信息
					if (type == 0)
					{
						//组织玩家信息
						this._userInfo.userVo.userid=this._socket.readInt();
						this._userInfo.userVo.username=this._socket.readString();
						this._userInfo.userVo.name=this._socket.readString();
						this._userInfo.userVo.headImage=this._socket.readBytes();
						this._userInfo.userVo.sex=this._socket.readByte();
//						this._userInfo.userVo.email=this._socket.readString();
//						this._userInfo.userVo.moible=this._socket.readString();
//						this._userInfo.userVo.score=this._socket.readInt();
						this._userInfo.userVo.money=this._socket.readFloat();
						this._userInfo.userVo.level=GameData.getLevel(this._global.userInfo.userVo.money);
//						this._userInfo.userVo.gold=this._socket.readInt();
						trace("收到玩家信息:" + this._userInfo.userVo.toString());
					}
					this.sendNotification(CLZNoticeName.LOGINMEDIATOR_RES_LOGIN, {type: type});
					break;
				}
				case Command.CMD_REQUESTFRIENDLIST: //好友列表
				{
					trace("Command.CMD_REQUESTFRIENDLIST");
					userid=this._socket.readString();
					type=this._socket.readByte();
					msg=this._socket.readString();
					this.sendNotification(CLZNoticeName.CHATROOMMEDIATOR_RES_SENDMESSAGE, {userid: userid, type: type, message: msg});
					break;
				}
				case Command.CMD_LOGIN:
				{
					trace("Command.CMD_LOGIN");
					type=this._socket.readInt();
					//登录成功，取玩家信息
					if (type == 0)
					{
						//组织玩家信息
						this._userInfo.userVo.userid=this._socket.readInt();
						this._userInfo.userVo.name=this._socket.readString();
						this._userInfo.userVo.sex=this._socket.readByte();
//						this._userInfo.userVo.email=this._socket.readString();
//						this._userInfo.userVo.moible=this._socket.readString();
//						this._userInfo.userVo.score=this._socket.readInt();
						this._userInfo.userVo.money=this._socket.readFloat();
//						this._userInfo.userVo.gold=this._socket.readInt();
						trace("收到玩家信息:" + this._userInfo.userVo.toString());
					}
					this.sendNotification(CLZNoticeName.LOGINMEDIATOR_RES_LOGIN, {type: type});
					break;
				}
//				case Command.CMD_CHATROOMMEDIATOR_SENDMESSAGE: //聊天
//				{
//					trace("Command.CMD_CHATROOMMEDIATOR_SENDMESSAGE");
////					userid=this._socket.readString();
////					type=this._socket.readByte();
//					msg=this._socket.readString();
//					this.sendNotification(CLZNoticeName.CHATROOMMEDIATOR_RES_SENDMESSAGE, {userid: "", type: 0, message: msg});
//					break;
//				}
				case Command.CMD_REGISTER:
				{

					trace("[ServerPacketProxy收到CMD_REGISTER]请求注册进入房间响应");
					errId=this._socket.readByte();
					if (errId == 0)
					{
						return;
					}
//					objData.data={userid: this._global.userInfo.userVo.userid};
//					this.sendNotification(CLZNoticeName.SHOW_WINDOWS_TIP, objData);
					break;
				}
				case Command.CMD_PLAYERS:
				{
					trace("Command.CMD_PLAYERS");
					this.roomPlayer();
					break;
				}
				case Command.CMD_ROOMINFO: //房间信息,底牌，玩家座位
				{
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).responseRoomInfo();
					break;
				}
				case Command.CMD_GameMessageList:
				{
					(facade.retrieveProxy(UserInfoProxy.NAME) as UserInfoProxy).responseGameMessageList();
					break;
				}
				case Command.CMD_REGISTER_MATCH:
				{
					break;
				}
				case Command.CMD_EXIT_MATCH_ME:
				{
					break;
				}
				case Command.CMD_IN_GAME_ROOM: //进入房间
				{
					(facade.retrieveProxy(GameRoomProxy.NAME) as GameRoomProxy).responseInGameRoom();
					break;
				}
				case Command.CMD_OUT_GAME_ROOM:
				{
					(facade.retrieveProxy(GameRoomProxy.NAME) as GameRoomProxy).responseOutGameRoom();
					break;
				}
				case Command.CMD_SITDOWN:
				{
					(facade.retrieveProxy(GameRoomProxy.NAME) as GameRoomProxy).responseSitDown();
					break;
				}
				case Command.CMD_STAND_UP:
				{
					objData.seatId=this._socket.readInt();
					objData.money=this._socket.readFloat();
					objData.isSystem=this._socket.readInt();
					this.sendNotification(CLZNoticeName.STAND_UP_RSP, objData);
					break;
				}
				case Command.CMD_START_GAME:
				{
					dealer=this._socket.readInt();
					objData.dealer=dealer;
					objData.card1=this._socket.readString();
					objData.card2=this._socket.readString();
					playingNum=this._socket.readInt();
					objData.arrPlayer=[];
					objData.arrSit=[];
					i;
					while (i < playingNum)
					{

						obj=new Object();
						obj.seatId=this._socket.readInt();
						obj.callMoney=this._socket.readFloat();
						obj.callType=GameData.contBlindPosition(dealer, obj.seatId, playingNum);
						objData.arrSit.push(obj.seatId);
						objData.arrPlayer.push(obj);
						i=(i + 1);
					}
					this.sendNotification(CLZNoticeName.START_GAME, objData);
					break;
				}
				case Command.CMD_OPERATION_NEXT:
				{
					objData.step=this._socket.readUInt(); //当前坐位id
					objData.seatId=this._socket.readUInt(); //当前坐位id
					objData.minCall=this._socket.readFloat(); //桌面最小叫多少
					objData.maxRaise=this._socket.readFloat(); //最小大加注多少
					objData.minRaise=this._socket.readFloat(); //最小加注多少
					objData.stake=this._socket.readFloat(); //玩家的筹码
//					Debug.traceObj(objData);
					this.sendNotification(CLZNoticeName.OPERATION_PALYER, objData);
					break;
				}
				case Command.CMD_SNAPCARDS_FLOP:
				{
					objData.card1=this._socket.readString();
					objData.card2=this._socket.readString();
					objData.card3=this._socket.readString();
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).showSnapCardsFlop(objData);
					break;
				}
				case Command.CMD_SNAPCARDS_TURN:
				{
					objData.card1=this._socket.readString();
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).showSnapCardsTurn(objData);
					break;
				}
				case Command.CMD_SNAPCARDS_RIVER:
				{
					objData.card1=this._socket.readString();
					(facade.retrieveProxy(RoomInfoProxy.NAME) as RoomInfoProxy).showSnapCardsRiver(objData);
					break;
				}
				case Command.CMD_OPERATION_SUCC:
				{
					objData.seatId=this._socket.readInt();
					objData.stake=this._socket.readFloat();
					objData.callChip=this._socket.readFloat();
					objData.lastAction=this._socket.readInt();
					this.sendNotification(CLZNoticeName.OPERATION_SUCC, objData);
					break;
				}
				case Command.CMD_SHOW:
				{
					playerNum=this._socket.readInt();
					objData.arrPlayer=[];
					i=0;
					while (i < playerNum)
					{

						obj=new Object();
						obj.seatId=this._socket.readInt();
						obj.isWin=this._socket.readInt();
						obj.card1=this._socket.readString();
						obj.card2=this._socket.readString();
						obj.cardType=this._socket.readInt();
						objData.arrPlayer.push(obj);
						i=(i + 1);
					}
					winCardNum=this._socket.readInt();
					objData.arrWinCard=[];
					i=0;
					while (i < winCardNum)
					{

						obj=new Object();
						obj.seatId=this._socket.readInt();
						obj.card1=this._socket.readString();
						obj.card2=this._socket.readString();
						obj.card3=this._socket.readString();
						obj.card4=this._socket.readString();
						obj.card5=this._socket.readString();
						objData.arrWinCard.push(obj);
						i=(i + 1);
					}
					this.sendNotification(CLZNoticeName.SHOW, objData);
					break;
				}
				case Command.CMD_POTS:
				{
					objData.potId=this._socket.readInt();
					objData.cardType=this._socket.readInt();
					winLen=this._socket.readInt();
					objData.arrWinPlayer=[];
					i;
					while (i < winLen)
					{

						obj=new Object();
						obj.seatId=this._socket.readInt();
						obj.userid=this._socket.readInt();
						obj.potMoney=this._socket.readFloat();
						obj.stake=this._socket.readFloat();
						obj.backCard1=this._socket.readString();
						obj.backCard2=this._socket.readString();
						obj.card1=this._socket.readString();
						obj.card2=this._socket.readString();
						obj.card3=this._socket.readString();
						obj.card4=this._socket.readString();
						obj.card5=this._socket.readString();
						objData.arrWinPlayer.push(obj);
						playerVo=(facade.retrieveProxy(InRoomPlayerDataProxy.NAME) as InRoomPlayerDataProxy).getInRoomPlayer(obj.userid);
						if (playerVo != null)
						{
							try
							{
								if (obj.card1.length == 2)
								{
									arrCardTypeTip=GameData.tip["cardType"].split("|");
									//%NAME% 牌型为%VALUE%
									cardStr=GameData.replaceStrValue(GameData.tip["MSG_PLAYER_CARD_TYPE"], "VALUE", arrCardTypeTip[objData.cardType] + " " + GameData.getCardIcon(obj.card1) + " " + GameData.getCardIcon(obj.card2) + " " + GameData.getCardIcon(obj.card3) + " " + GameData.getCardIcon(obj.card4) + " " + GameData.getCardIcon(obj.card5));
									cardStr=GameData.replaceStrValue(cardStr, "NAME", playerVo.name);
									this.sendNotification(CLZNoticeName.CHAT_SYSTEM_TIP, cardStr);
								}
								if (objData.potId == 0)
								{
									//%NAME% 赢得主池%VALUE
									msg=GameData.replaceStrValue(GameData.replaceStrValue(GameData.tip["MSG_PLAYER_WIN_PORT1"], "VALUE", obj.potMoney), "NAME", playerVo.name);
//									msg=GameData.replaceStrValue(GameData.replaceStrValue(GameData.tip["MSG_PLAYER_WIN_PORT1"], "VALUE", obj.potMoney / winLen), "NAME", playerVo.name);
								}
								else
								{
									//%NAME% 赢得第%NUM%边池%VALUE%
									msg=GameData.replaceStrValue(GameData.replaceStrValue(GameData.replaceStrValue(GameData.tip["MSG_PLAYER_WIN_PORT2"], "VALUE", obj.potMoney), "NAME", playerVo.name), "NUM", objData.potId);
//									msg=GameData.replaceStrValue(GameData.replaceStrValue(GameData.replaceStrValue(GameData.tip["MSG_PLAYER_WIN_PORT2"], "VALUE", obj.potMoney / winLen), "NAME", playerVo.name), "NUM", objData.potId);
								}
								this.sendNotification(CLZNoticeName.CHAT_SYSTEM_TIP, msg);
							}
							catch (e:Error)
							{
							}
						}
						i=(i + 1);
					}
					this.sendNotification(CLZNoticeName.POTS, objData);
					break;
				}
				case Command.CMD_CUR_POT:
				{
					potLen=this._socket.readInt();
					var arrPot:Array=[];
					i;
					while (i < potLen)
					{

						potNum=this._socket.readInt();
						potMoney=this._socket.readFloat();
						arrPot.push([potNum, potMoney]);
						//第%NUM%边池形成
						this.sendNotification(CLZNoticeName.CHAT_SYSTEM_TIP, GameData.replaceStrValue(GameData.tip["MSG_PORT_NUMBER"], "NUM", (potNum + 1)));
						i=(i + 1);
					}
					this.sendNotification(CLZNoticeName.CUR_POT, arrPot);
					break;
				}
				case Command.CMD_CHAT:
				{
					objData=new Object();
					objData.type=this._socket.readByte();
					objData.userid=this._socket.readInt();
//					objData.userid=1;
					objData.name=this._socket.readString();
					objData.msg=this._socket.readString();
					this.sendNotification(CLZNoticeName.CHAT_RES, objData);
					break;
				}
				case Command.CMD_GAME_OVER:
				{ //本牌局结束，等待下一局
					this.sendNotification(CLZNoticeName.CHAT_SYSTEM_TIP, GameData.tip["MSG_GAME_OVER"].toString());
					this.sendNotification(CLZNoticeName.GAME_OVER);
					break;
				}
				case Command.CMD_AGAIN_BUYIN:
				{
					objData.seatId=this._socket.readInt();
					objData.errId=this._socket.readInt();
					objData.stake=this._socket.readFloat();
					objData.money=this._socket.readFloat();
					this.sendNotification(CLZNoticeName.AGAIN_SIT_BUYIN_RES, objData);
					break;
				}
				case Command.CMD_GIVE_CHIP:
				{
					isErr=this._socket.readInt();
					trace(isErr + "isErr");
					if (isErr != 0)
					{
						return;
					}
					objData.fromMid=this._socket.readUInt();
					objData.toMid=this._socket.readUInt();
					objData.chip=this._socket.readUInt();
					this.sendNotification(CLZNoticeName.GIVE_CHIP_RES, objData);
					break;
				}
				case Command.CMD_GIVE_GIFT:
				{
					objData.errId=this._socket.readInt();
					objData.userid=this._socket.readUInt();
					objData.gold=this._socket.readUInt();
					objData.toMid=this._socket.readUInt();
					objData.pcate=this._socket.readInt();
					objData.pframe=this._socket.readInt();
					objData.num=this._socket.readInt();
					if (objData.errId != 0)
					{
						switch (objData.errId)
						{
							case -9:
							{
								this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["BAG_FULL"]});
								break;
							}
							case -6:
							{
								this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["SEND_BUYIN_PROP_ERR_GOLD"]});
								break;
							}
							default:
							{
								this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["BUYIN_SEND_ERR"]});
								break;
							}
						}
						return;
					}
					if (objData.pcate <= 10)
					{
					}
					if (objData.errId == 0)
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["BUYIN_SEND_SUCC"]});
					}
					trace("Command.CMD_GIVE_GIFT");
					this.sendNotification(CLZNoticeName.GIVE_GIFT_RES, objData);
					break;
				}
				case Command.CMD_CHANGE_SEATICO:
				{
					objData.errId=this._socket.readByte();
					objData.ico=this._socket.readInt();
					this.sendNotification(CLZNoticeName.UPDATE_PERSON_ID_RES, objData);
					break;
				}case Command.CMD_CHANGE_HEADIMAGE:
				{
					objData.errId=this._socket.readByte();					
					this.sendNotification(CLZNoticeName.UPDATE_PERSON_HEAD_RES, objData);
					break;
				}
				case Command.CMD_USE_PROP:
				{
					objData.errId=this._socket.readInt();
					objData.useMid=this._socket.readUInt();
					objData.gold=this._socket.readUInt();
					objData.toMid=this._socket.readUInt();
					objData.pcate=this._socket.readInt();
					objData.pframe=this._socket.readInt();
					objData.type=this._socket.readInt();
					if (objData.errId != 0)
					{
						switch (objData.errId)
						{
							case -9:
							{
								this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["BAG_FULL"]});
								break;
							}
							case -6:
							{
								this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["USE_BUYIN_PROP_ERR_GOLD"]}); //使用失败,金币不足
								break;
							}
							default:
							{
								this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["USE_PROP_ERR"]}); //使用道具失败
								break;
							}
						}
						return;
					}
					this.sendNotification(CLZNoticeName.USE_PROP_RES, objData);
					break;
				}
				case Command.CMD_UPDATE_CORNUCOPIA:
				{
					var objData:Object={};
					objData.toCornucopia=this._socket.readFloat();
					objData.offsetCornucopia=this._socket.readFloat();
					objData.updateCornucopiaSecond=this._socket.readUInt();
					this.sendNotification(CLZNoticeName.UPDATE_CORNUCOPIA_GOLD, objData);
					break;
				}
				case Command.CMD_REWARD_CORNUCOPIA:
				{
					objData.userid=this._socket.readUInt();
					objData.name=this._socket.readString();
					objData.cardType=this._socket.readInt();
					objData.money=this._socket.readFloat();
					objData.roomId=this._socket.readInt();
					this.sendNotification(CLZNoticeName.GET_REWARD_CORNUCOPIA, objData);
					break;
				}
				case Command.CMD_TODAYCORNUCOPIALIST:
				{
					objData.userid=this._socket.readUInt();
					objData.name=this._socket.readString();
					objData.cardType=this._socket.readInt();
					objData.money=this._socket.readFloat();
					objData.roomId=this._socket.readInt();
					this.sendNotification(CLZNoticeName.CORNUCOPIA_TODAY_LIST_RES, objData);
					break;
				}
				case Command.CMD_MYCORNUCOPIALIST:
				{
					objData.userid=this._socket.readUInt();
					objData.name=this._socket.readString();
					objData.cardType=this._socket.readInt();
					objData.money=this._socket.readFloat();
					objData.roomId=this._socket.readInt();
					this.sendNotification(CLZNoticeName.CORNUCOPIA_MY_LIST_RES, objData);
					break;
				}
				case Command.CMD_NOTICE:
				{
					objData.type=this._socket.readInt();
					objData.userid=this._socket.readUInt();
					objData.name=this._socket.readString();
					objData.msg=this._socket.readString();
					this.sendNotification(CLZNoticeName.GAME_NOTICE, objData);
					break;
				}
				case Command.CMD_HONOR_TIP:
				{
					objData.pcate=this._socket.readInt();
					objData.pframe=this._socket.readInt();
					objData.money=this._socket.readFloat();
					this.sendNotification(CLZNoticeName.SHOW_HONOR_TIP, objData);
					break;
				}
				case Command.CMD_UPDATE_RANK:
				{
					mid=this._socket.readUInt();
					rank=this._socket.readUInt();
					winRank=this._socket.readUInt();
					if (this._global.userInfo.userVo.userid == mid)
					{
						this._global.userInfo.userVo.winRank=winRank;
						this._global.userInfo.rank=rank;
					}
					playerVo=(facade.retrieveProxy(InRoomPlayerDataProxy.NAME) as InRoomPlayerDataProxy).getInRoomPlayer(mid);
					if (playerVo != null)
					{
						playerVo.rank=rank;
						playerVo.winRank=winRank;
					}
					break;
				}
				case Command.CMD_RENEW_GIFT:
				{
					id=this._socket.readInt();
					errId=this._socket.readInt();
					sumGold=this._socket.readFloat();
					if (errId == 0)
					{
						this._global.userInfo.money=sumGold;
						this.sendNotification(CLZNoticeName.RENEW_GIFT_RES, id);
					}
					else
					{
						strErr;
						if (errId == -1)
						{
							strErr=GameData.tip["GAME_GOLD_NOT_ENOUGH"];
						}
						else
						{
							strErr=GameData.tip["OTHER_ERR"];
						}
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: strErr});
					}
					break;
				}
				case Command.CMD_BANK_DEPOSIT:
				case Command.CMD_BANK_WITHDRAW:
				case Command.CMD_BANK_TRANSFER:
				{
					errId=this._socket.readInt();
					if (errId == 0)
					{
						this._global.userInfo.bankAssets=this._socket.readUInt();
						this._global.userInfo.money=this._socket.readFloat();
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["OPERATE_BANK_SUCC"]});
					}
					else if (errId == -1)
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["GAME_GOLD_NOT_ENOUGH"]});
					}
					else if (errId == -3)
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["OTHER_ERR"]});
					}
					else
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["PW_ERR"]});
					}
					break;
				}
				case Command.CMD_BANK_MODIFY:
				{
					errId=this._socket.readInt();
					if (errId == 0)
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["MODIFY_PW_SUCC"]});
					}
					else if (errId == -1)
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["MODIFY_PW_ERR"]});
					}
					else
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["OTHER_ERR"]});
					}
					break;
				}
				case Command.CMD_BANK_TRANSFER_NOTICE:
				{
					fromMid=this._socket.readUInt();
					fromName=this._socket.readString();
					toGold=this._socket.readUInt();
					this._global.userInfo.bankAssets=this._socket.readUInt();
					this._global.userInfo.money=this._socket.readFloat();
					msg=GameData.replaceStrValue(GameData.replaceStrValue(GameData.tip["BANK_TRANSFER_NOTICE"], "NAME", fromName), "NUM", toGold);
					this.sendNotification(CLZNoticeName.SHOW_WINDOWS_TIP, {okNoticeName: CLZNoticeName.HIDE_WINDOWS_TIP, tip: msg, tipTitle: GameData.tip["SYSTEM_TIP"], data: null, isCancel: false});
					break;
				}
				case Command.CMD_GAME_ROOM_SOCKET_CLOSE:
				{
					trace("CMD_GAME_ROOM_SOCKET_CLOSE");
					(facade.retrieveProxy(GameRoomProxy.NAME) as GameRoomProxy).responseCloseSocketOutGameRoom();
					break;
				}
				case Command.CMD_CLOSE_AGIAN_GAME_ROOM:
				{
					roomId=this._socket.readUInt();
					if (roomId != 0)
					{
						roomVo=GameData.getRoomInfoById(GameData.ALL, roomId);
						roomVo.id=roomId;
						this.sendNotification(CLZNoticeName.ENTER_GAME_ROOM_REQ, roomVo);
					}
					break;
				}
				case Command.CMD_REMOVE_GIFT:
				{
					mid=this._socket.readUInt();
					this.sendNotification(CLZNoticeName.GIFT_CANCEL_RES, mid);
					break;
				}
				case Command.CMD_SYSTEM_GIVE_MONEY:
				{
					count=this._socket.readInt();
					money=this._socket.readFloat();
					sumMoney=this._socket.readInt();
					this._global.userInfo.money=sumMoney;
					msg=GameData.replaceStrValue(GameData.tip["SYSTEM_SEND_MONEY"], "MONEY", money);
					msg=GameData.replaceStrValue(msg, "NUM", count);
					this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: msg});
					obj;
					this.sendNotification(CLZNoticeName.CHAT_RES, obj);
					break;
				}
				case Command.CMD_FRIEND_TO_REQUEST:
				{
					fromMid=this._socket.readUInt();
					toMid=this._socket.readUInt();
					this.sendNotification(CLZNoticeName.FRIEND_TO_REQUEST_RES, [fromMid, toMid]);
					break;
				}
				case Command.CMD_FRIEND_RETURN:
				{
					fromMid=this._socket.readUInt();
					toMid=this._socket.readUInt();
					type=this._socket.readInt();
					this.sendNotification(CLZNoticeName.FRIEND_RETURN_RES, [fromMid, toMid, type]);
					break;
				}
				case Command.CMD_TRACK_ROOM:
				{
					errId=this._socket.readInt();
					roomId=this._socket.readInt();
					if (errId == 0)
					{
						roomVo=GameData.getRoomInfoById(GameData.ALL, roomId);
						this.sendNotification(CLZNoticeName.ENTER_GAME_ROOM_REQ, roomVo);
					}
					else
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["NOT_IN_GAME_ROOM"]});
					}
					break;
				}
				case Command.CMD_FACE:
				{
					objData.userid=this._socket.readUInt();
					objData.pcate=this._socket.readInt();
					objData.pframe=this._socket.readInt();
					this.sendNotification(CLZNoticeName.FACE_RES, objData);
					break;
				}
				case Command.CMD_ONLINE_MORE_FRIEND_LIST:
				{
					count=this._socket.readInt();
					arr;
					i;
					while (i < count)
					{

						arr.push(this._socket.readUInt());
						i=(i + 1);
					}
					this._userInfo.updateMoreFriendState(arr);
					break;
				}
				case Command.CMD_ONLIN_FRIEND:
				{
					this._userInfo.updateFriendState(this._socket.readUInt(), 1);
					break;
				}
				case Command.CMD_OFFLINE_FRIEND:
				{
					this._userInfo.updateFriendState(this._socket.readUInt(), 0);
					break;
				}
				case Command.CMD_MY_CARD_AGAIN:
				{
					card1=this._socket.readString();
					card2=this._socket.readString();
					this.sendNotification(CLZNoticeName.SHOW_MY_CARD_AGAIN, [card1, card2]);
					break;
				}
				case Command.CMD_ONLINE_TIME:
				{
					onLineTime=this._socket.readUInt();
					onLineNum=this._socket.readUInt();
					this.sendNotification(CLZNoticeName.ONLINE_TIME_NUM, [onLineTime, onLineNum]);
					break;
				}
				case Command.CMD_INIT_SET:
				{
					volume=this._socket.readInt();
//					SoundManage.volume=volume / 100;
					break;
				}
				case Command.CMD_UPDATE_SERVER_TIP:
				{
					time=this._socket.readUInt();
					this.sendNotification(CLZNoticeName.UPDATE_SERVER_TIP, time);
					break;
				}
				case Command.CMD_FAST_ENTER_ROOM:
				{
					this._global._isRequestFast=false;
					errId=this._socket.readByte();
					roomId=this._socket.readInt();
					if (roomId == -1)
					{
						this.sendNotification(CLZNoticeName.SHOW_MOVE_TIP, {tip: GameData.tip["NOT_ROOM"]}); //没找到合适的房间
					}
					else
					{
						this.sendNotification(CLZNoticeName.FAST_ENTER_ROOM_RSP, roomId);
					}

//					else
//					{
//						roomVo=GameData.getRoomInfoById(GameData.ALL, roomId);
////						roomVo=this._global.constRoomVoEnter(roomVo);
//						roomVo.id=roomId;
//						roomVo.randomSit=1;
//						this.sendNotification(CLZNoticeName.ENTER_GAME_ROOM_REQ, roomVo);
//					}
					break;
				}
				case Command.CMD_CLOSE_GAME_TIME:
				{
//					if (this._global.seatId != 0)
					{
						this.sendNotification(CLZNoticeName.STAND_UP);
					}
					time=this._socket.readInt();
					//您的帐号存在异常，被系统锁定{font color='#ff0000'} %TIME% {/font}个小时
					strTip=GameData.replaceStrValue(GameData.tip["CLOSE_GAME_TIME"], "TIME", time);
					objData;
					this.sendNotification(CLZNoticeName.SHOW_WINDOWS_TIP, objData);
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}

		private function readTest():void
		{
			return;
		}

		public function connect(host:String, port:int):void
		{
			this._userInfo=GameData.getInstance().userInfo;
			trace(host, port);
			this._socket.connect(host, port);
			return;
		}

		/**
		 * 服务端将当前玩家房间用户详细数据，在初次进房发回
		 */
		public function roomPlayer():void
		{
			var sitdown:int=0;
			var playerVo:PlayerVo=null;
			var playerCount:*=this._socket.readInt();
			var count:int=0;
			while (count < playerCount)
			{

				sitdown=this._socket.readInt();
				playerVo=new PlayerVo();
				playerVo.seatId=sitdown;
				playerVo.userid=this._socket.readUInt();
//				playerVo.openId=this._socket.readInt();
//				playerVo.personId=this._socket.readInt();
				playerVo.sex=this._socket.readByte();
				playerVo.initSex=playerVo.sex;
				playerVo.name=this._socket.readString();
				playerVo.icon=this._socket.readString();
//				playerVo.vip=this._socket.readInt();
//				playerVo.gold=this._socket.readUInt();
				playerVo.money=this._socket.readFloat();
//				playerVo.sumGame=this._socket.readUInt();
//				playerVo.winGame=this._socket.readUInt();
//				playerVo.rank=this._socket.readUInt();
//				playerVo.winRank=this._socket.readUInt();
//				playerVo.giftPcate=this._socket.readUInt();
//				playerVo.giftPframe=this._socket.readUInt();
//				playerVo.banSpeak=this._socket.readInt();
//				playerVo.yellowvip=this._socket.readInt();
//				playerVo.isyearvip=this._socket.readInt();
				(facade.retrieveProxy(InRoomPlayerDataProxy.NAME) as InRoomPlayerDataProxy).inRoom(playerVo);
				if (sitdown > 0)
				{
					(facade.retrieveProxy(InRoomPlayerDataProxy.NAME) as InRoomPlayerDataProxy).sitDown(playerVo);
				}
				count=count + 1;
			}
			return;
		}



		//30秒发一次空闲检测
		public function hbHandler():void
		{
			this._socket.writeBegin(Command.CMD_HB);
			this._socket.writeEnd();
			this._socket.sendCmd();
			CLZTiming.add(30, this.hbHandler);
			return;
		}


		public function requestTestAutoAdd():void
		{
			var autoCount:int=0;
			while (autoCount <= 8)
			{
				this._socket.writeBegin(Command.CMD_CHATROOMMEDIATOR_SENDMESSAGE);
				this._socket.writeString("abc");
				this._socket.writeEnd();
				this._socket.sendCmd();
				autoCount++
				trace(autoCount);
			}
			this.sendNotification(CLZNoticeName.CHATROOMMEDIATOR_TEST_AUTOADD_FINISH);
		}

		/**
		 * 请求好友列表
		 */
		public function requestFriendList():void
		{
			this._socket.writeBegin(Command.CMD_REQUESTFRIENDLIST);
			this._socket.writeInt(_userInfo.userVo.userid);
			this._socket.writeEnd();
			this._socket.sendCmd();
		}

		/**
		 * 请求房间列表
		 */
		public function requestRoomList():void
		{
			this._socket.writeBegin(Command.CMD_RoomList);
			this._socket.writeByte(0);
			this._socket.writeEnd();
			this._socket.sendCmd();
		}
		var autoCount:int=0;

		public function testAutoAddHandler(bodyData:Object):void
		{
			this._socket.writeBegin(8000);
			this._socket.writeString(bodyData.toString());
			this._socket.writeEnd();
			this._socket.sendCmd();
			trace(autoCount++);
//			this.sendNotification(CLZNoticeName.CHATROOMMEDIATOR_TEST_Send_FINISH, bodyData);
			if (autoCount >= 10000)
			{
				CLZTiming.remove(this.testAutoAddHandler);
				this.sendNotification(CLZNoticeName.CHATROOMMEDIATOR_TEST_AUTOADD_FINISH);
			}
			else
			{
				CLZTiming.add(0.04, this.testAutoAddHandler, bodyData);
			}

			return;
		}

		public function requestRoomInfo(room:RoomVo=null):void
		{
			trace("[ServerPacketProxy.requestRoomInfo]请求注册进入房间:" + room.id);
			this._socket.writeBegin(Command.EnterRoomCmd);
//			this._socket.writeBegin(Command.CMD_REGISTER);
			this._socket.writeByte(0); //通知进入
			this._socket.writeInt(room.id);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function getOutRoom(param1:Object=null):void
		{
			this._socket.writeBegin(Command.EnterRoomCmd);
			this._socket.writeByte(3);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 请求坐下，seatid，筹码money
		 * @param _data
		 */
		public function sitRequest(_data:Object=null):void
		{
			this._socket.writeBegin(Command.EnterRoomCmd);
			this._socket.writeByte(2);
			this._socket.writeInt(_data.seatId);
			this._socket.writeFloat(_data.money);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 设置房间大小盲基础信息
		 * @param _data
		 */
		public function setRoomInfoRequest(_data:Object=null):void
		{
			this._socket.writeBegin(Command.CMD_GameRoomCmd);
			this._socket.writeByte(100);
			this._socket.writeString(_data.roomname);
			this._socket.writeUint(_data.roomid);
			this._socket.writeUint(_data.seatnum);
			this._socket.writeFloat(_data.minBlind);
			this._socket.writeFloat(_data.maxBlind);
			this._socket.writeFloat(_data.minStake);
			this._socket.writeFloat(_data.maxStake);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**从座位站起
		 *
		 * @param param1
		 */
		public function standSit(dataObj:Object=null):void
		{
//			this._socket.writeBegin(Command.CMD_STAND_UP);
			this._socket.writeBegin(Command.EnterRoomCmd);
			this._socket.writeByte(5);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 请求登录
		 * @param data
		 */
		public function requestLogin(data:Object=null):void
		{
			this._socket.writeBegin(Command.CMD_LOGIN);
			this._socket.writeByte(0);
			this._socket.writeString(data.userid);
			this._socket.writeString(data.password);
			this._socket.writeInt(data.key);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 发消息给服务器
		 * @param data
		 */
		public function requestSendMessage(data:Object=null):void
		{
			this._socket.writeBegin(Command.CMD_CHATROOMMEDIATOR_SENDMESSAGE);
//			this._socket.writeString(data.userid);//保密数据，在服务端存储
//			this._socket.writeByte(data.type);
			this._socket.writeString(data.message);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 再次买入
		 * @param data
		 */
		public function requestAgaingSitBuyIn(data:Object=null):void
		{
			this._socket.writeBegin(Command.CMD_AGAIN_BUYIN);
			this._socket.writeFloat(data.money);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 赠送chip给玩家
		 * @param data
		 */
		public function requestGiveChip(data:Object=null):void
		{
			trace("Command.CMD_GIVE_CHIP");
			this._socket.writeBegin(Command.CMD_GIVE_CHIP);
			this._socket.writeUint(data.toMid);
			this._socket.writeUint(data.chip);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 给一批玩家赠送礼品
		 * @param dataObj
		 */
		public function requestGiveGift(dataObj:Object=null):void
		{
			var userCount:*=dataObj.arrMid.length;
			var index:int=0;
			while (index < userCount)
			{

				this._socket.writeBegin(Command.CMD_GIVE_GIFT);
				this._socket.writeUint(dataObj.arrMid[index]);
				this._socket.writeInt(dataObj.type);
				this._socket.writeInt(dataObj.giftId);
				this._socket.writeInt(dataObj.num);
				this._socket.writeEnd();
				this._socket.sendCmd();
				index=index + 1;
			}
			return;
		}

		public function requestUseProp(dataObj:Object):void
		{
			this._socket.writeBegin(Command.CMD_USE_PROP);
			this._socket.writeUint(dataObj.toMid);
			this._socket.writeInt(dataObj.pcate);
			this._socket.writeInt(dataObj.pframe);
			this._socket.writeInt((int(dataObj.type) - 1));
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestUpdatePesrson(dataObj:PropVo):void
		{
			this._socket.writeBegin(Command.CMD_LobbyCmd);
			this._socket.writeShort(Command.CMD_CHANGE_SEATICO);
//			this._socket.writeUint(this._global.userInfo.userVo.userid);
			this._socket.writeInt(dataObj.pframe);
//			this._socket.writeInt(dataObj.pframe);
//			this._socket.writeInt(0);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}
		public function requestUpdateHeadImage(bytes:ByteArray):void
		{
			this._socket.writeBegin(Command.CMD_LobbyCmd);
			this._socket.writeShort(Command.CMD_CHANGE_HEADIMAGE);
			this._socket.writeBytes(bytes);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}
		public function requestRenew(dataObj:PropVo):void
		{
			this._socket.writeBegin(Command.CMD_RENEW_GIFT);
			this._socket.writeUint(dataObj.id);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestRemoveGift():void
		{
			this._socket.writeBegin(Command.CMD_REMOVE_GIFT);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestDeposit(param1:uint):void
		{
			this._socket.writeBegin(Command.CMD_BANK_DEPOSIT);
			this._socket.writeUint(param1);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestWithdraw(param1:uint, param2:String):void
		{
			this._socket.writeBegin(Command.CMD_BANK_WITHDRAW);
			this._socket.writeUint(param1);
			this._socket.writeString(param2);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestTransfer(param1:uint, param2:uint, param3:String):void
		{
			this._socket.writeBegin(Command.CMD_BANK_TRANSFER);
			this._socket.writeUint(param1);
			this._socket.writeUint(param2);
			this._socket.writeString(param3);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 请求修改密码
		 * @param dataObj
		 */
		public function requestModifyPW(dataObj:Object):void
		{
			this._socket.writeBegin(Command.CMD_BANK_MODIFY);
			this._socket.writeString(dataObj.oldPW);
			this._socket.writeString(dataObj.newPW);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 下注请求,actionType,chip
		 * @param operateData
		 */
		public function operationRequest(operateData:Object=null):void
		{
//			this._socket.writeBegin(Command.CMD_OPERATION_REQUEST);
			this._socket.writeBegin(Command.CMD_GameRoomCmd);
			this._socket.writeByte(103);
			this._socket.writeInt(operateData.step);
			this._socket.writeInt(operateData.type);
			this._socket.writeFloat(operateData.chip);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 聊天请求
		 * @param msg
		 * @param type
		 */
		public function requestChat(msg:String, type:int):void
		{
			trace("[发聊天]");
			this._socket.writeBegin(Command.CMD_CHAT);
			msg=this._wordFilter.filterMsg(msg);
			this._socket.writeByte(type);
			this._socket.writeString(msg);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 请求加好友
		 * @param userid
		 */
		public function requestToAddFriend(userid:uint):void
		{
			this._socket.writeBegin(Command.CMD_FRIEND_TO_REQUEST);
			this._socket.writeInt(userid);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestReturnAddFriend(param1:uint, param2:int):void
		{
			this._socket.writeBegin(Command.CMD_FRIEND_RETURN);
			this._socket.writeUint(param1);
			this._socket.writeInt(param2);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 请求追踪好友所在房间
		 * @param userid
		 */
		public function requestTrackRoom(userid:uint):void
		{
			this._socket.writeBegin(Command.CMD_TRACK_ROOM);
			this._socket.writeUint(userid);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestFace(pcate:int, pframe:int):void
		{
//			this._socket.writeBegin(Command.CMD_FACE);
			this._socket.writeBegin(Command.CMD_GameRoomCmd);
			this._socket.writeByte(104);
			this._socket.writeInt(pcate);
			this._socket.writeInt(pframe);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		public function requestSet(param1:int):void
		{
			this._socket.writeBegin(Command.CMD_INIT_SET);
			this._socket.writeInt(param1);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

		/**
		 * 请求快速快速游戏
		 */
		public function requestFastEnterRoomData():void
		{
			if (this._global._isRequestFast)
			{
				return;
			}
			this._global._isRequestFast=true;
//			this._socket.writeBegin(Command.CMD_FAST_ENTER_ROOM);
			this._socket.writeBegin(Command.EnterRoomCmd);
//			this._socket.writeUint(this._global.userInfo.userVo.userid);
			this._socket.writeByte(4);
			this._socket.writeEnd();
			this._socket.sendCmd();
			return;
		}

//===============Write操作
		public function writeTGW(txt:String, length:int):void
		{
			return this._socket.writeTGW(txt, length);
		}

		/**
		 * 写入开始部分，2头部+4包体长度+2命令标识+4用户id+4empty1+4empty2=22
		 * @param cmdId
		 */
		public function writeBegin(cmdId:uint):void
		{
			return this._socket.writeBegin(cmdId);
		}

		/**
		 * 写入结束
		 */
		public function writeEnd():void
		{
			return this._socket.writeEnd();
		}

		/**
		 * 写入4个字节到包packetBody,包长度加4
		 * @param num
		 */
		public function writeInt(num:int):void
		{
			return this._socket.writeInt(num);
		}
		public function writeFloat(num:Number):void
		{
			return this._socket.writeFloat(num);
		}
		/**
		 *  写入无符号整数,4个字节到包packetBody,包长度加4
		 * @param num
		 */
		public function writeUint(num:uint):void
		{
			return this._socket.writeUint(num);
		}

		/**
		 *  写入2个字节到包packetBody,包长度加2
		 * @param myShort
		 */
		public function writeShort(myShort:int):void
		{
			return this._socket.writeShort(myShort);
		}

		/**
		 *  写入1个字节到包packetBody,包长度加1
		 * @param myByte
		 */
		public function writeByte(myByte:int):void
		{
			return this._socket.writeByte(myByte);
		}

		/**
		 * 根据指定的编码写入字符串信息Strlen+1|bytes
		 * @param txt
		 * @param encoding
		 */
		public function writeString(txt:String, encoding:String="utf-8"):void
		{
			return this._socket.writeString(txt, encoding);
		}

		/**
		 * 将对象以 AMF 序列化格式写入字节数组
		 * @param obj
		 */
		public function writeBinary(obj:Object):void
		{
			return this._socket.writeBinary(obj);
		}

		public function writeDate(datetime:Date):void
		{
			return this._socket.writeDate(datetime);
		}

		public function getHead():int
		{
			return this._socket.getHead();
		}

		public function getLength():int
		{
			return this._socket.getLength();
		}

		public function getCmd():int
		{
			return this._socket.getCmd();
		}

		public function getBodyLen():int
		{
			return this._socket.getBodyLen();
		}

		public function readBegin():void
		{
			return this._socket.readBegin();
		}

		public function readInt():int
		{
			return this._socket.readInt();
		}
		public function readFloat():Number
		{
			return this._socket.readFloat();
		}
		public function readUInt():uint
		{
			return this._socket.readUInt();
		}

		public function readShort():int
		{
			return this._socket.readShort();
		}

		public function readByte():int
		{
			return this._socket.readByte();
		}
		public function readBytes():ByteArray
		{
			return this._socket.readBytes();
		}
		public function readString():String
		{
			return this._socket.readString();
		}

		public function readgb2132String():String
		{
			return this._socket.readgb2132String();
		}

		public function readBinary():Object
		{
			return this._socket.readBinary();
		}

		public function readXml():XML
		{
			return this._socket.readXml();
		}

		public function readDateString():String
		{
			return this._socket.readDateString();
		}

		public function readDate():Date
		{
			return this._socket.readDate();
		}

		public function sendCmd():void
		{
			return this._socket.sendCmd();
		}
	}
}
